<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<tiles:insertDefinition name="layout">
	<tiles:putAttribute name="head">
		<script type="text/javascript">
			$(function() {
				$(".confirm").confirmDialog(function(data) {
					helper.showMsg(data, {
						okHandler : function() {
							location.reload();
						}
					});
				});

				$(".remark").change(function() {

					var form = $(this).closest("form");

					var url = "../orderlesson/doRemarkLog";
					$.post(url, form.serialize());
				});

				$(".ajax").anchorAjax(function() {
					location.reload();
				});
			});
		</script>
	</tiles:putAttribute>
	<tiles:putAttribute name="mainBody">
		<ul class="breadcrumb">
			<s:url action="listDailyLesson" namespace="/lesson" id="listDailyLesson">
				<s:param name="startDate" value="startDate"></s:param>
			</s:url>
			<li><a href="${listDailyLesson}">当日课程</a> <span class="divider">/</span></li>
			<li class="active">听课情况</li>
		</ul>
		<div class="page-header">
			<h1>
				${lesson.name}<small> <strong> ${lesson.classroom.name}</strong></small>
			</h1>
		</div>
		<div>
			Teacher: <strong> <s:iterator value="#lesson.teachings" var="teaching" status="status">
								${teaching.teacher.name}
								<s:if test="!status.last">,</s:if>
				</s:iterator>
			</strong>
			<s:date name="#lesson.beginTime" format="yyyy-MM-dd" />
			${lesson.timespan}
			<s:if test="#lesson.canceled">
				<span class="label">已取消</span>
			</s:if>
			<s:if test="#lesson.canceled">
				<s:url namespace="/lesson" action="doResumeLesson" id="doResumeLesson">
					<s:param name="id" value="#lesson.id"></s:param>
				</s:url>
				<a href="${doResumeLesson}" class="btn confirm" title="恢复该课程">恢复</a>
			</s:if>
			<s:else>
				<s:url namespace="/lesson" action="doCancelLesson" id="doCancelLesson">
					<s:param name="id" value="#lesson.id"></s:param>
				</s:url>
				<a href="${doCancelLesson}" class="btn confirm" title="取消该课程">取消</a>
			</s:else>
		</div>
		<table class="table">
			<caption></caption>
			<thead>
				<tr>
					<th>Name</th>
					<th>Lesson</th>
					<th>Course</th>
					<th>Time</th>
					<th>Teacher Mark</th>
					<th>Mark</th>
					<th>Action</th>
				</tr>
			</thead>
			<tbody>
				<s:iterator value="logs" var="log">
					<tr>
						<td><s:if test="leaveEarly">
								<i class="icon-download" title="早退"></i>
							</s:if> <s:if test="beLate">
								<i class="icon-time" title="迟到"></i>
							</s:if> <s:url id="viewLogByTime" action="viewLogByTime" namespace="/log">
								<s:param name="id" value="student.id"></s:param>
							</s:url> <a href="${viewLogByTime}"> ${log.student.name}(${log.student.stuId}) </a> <s:if test="mark.toString() == 'Good'">
								<i class="icon-thumbs-up" title="Good"></i>
							</s:if> <s:elseif test="mark.toString()== 'Bad'">
								<i class="icon-thumbs-down" title="Bad"></i>
							</s:elseif> <s:if test="!valid">
								<span class="label">不统计课时</span>
							</s:if></td>
						<td>${log.lesson.name }</td>
						<td>${log.signCourse.course.name}</td>
						<td><s:date name="createTime" format="yyyy-MM-dd HH:mm:ss" /></td>
						<td>
							<form style="display: inline;" action="doRemarkLog">
								<input type="hidden" name="id" value="${log.id}" /><input name="remark" type="text" class="remark" value="${log.teacherRemark}" />
							</form> <s:url action="doMarkGoodOrderLesson" namespace="/orderlesson" id="doMarkGoodOrderLesson">
								<s:param name="id" value="id"></s:param>
							</s:url> <a href="${doMarkGoodOrderLesson}" class="ajax">
								<i class="icon-thumbs-up"></i>
							</a> <s:url action="doMarkBadOrderLesson" namespace="/orderlesson" id="doMarkBadOrderLesson">
								<s:param name="id" value="id"></s:param>
							</s:url> <a href="${doMarkBadOrderLesson}" class="ajax">
								<i class="icon-thumbs-down"></i>
							</a>
						</td>
						<td><s:url action="doLateOrderLesson" namespace="/orderlesson" id="doLateOrderLesson">
								<s:param name="id" value="id"></s:param>
							</s:url> <s:url action="doEarlyOrderLesson" namespace="/orderlesson" id="doEarlyOrderLesson">
								<s:param name="id" value="id"></s:param>
							</s:url> <s:url action="doResetOrderLesson" namespace="/orderlesson" id="doResetOrderLesson">
								<s:param name="id" value="id"></s:param>
							</s:url>
							<div class="btn-group">
								<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
									上课情况标注 <span class="caret"></span>
								</a>
								<ul class="dropdown-menu">
									<s:if test="!beLate">
										<li><a title="设置该学员为迟到" class="confirm" href="${doLateOrderLesson}">迟到</a></li>
									</s:if>
									<s:if test="!leaveEarly">
										<li><a title="设置该学员为早退" class="confirm" href="${doEarlyOrderLesson}">早退</a></li>
									</s:if>
									<li><a title="重置该次订课状态" class="confirm" href="${doResetOrderLesson}">重置</a></li>
								</ul>
							</div></td>
						<td><s:if test="valid">
								<s:url action="doUnValidOrderLesson" namespace="/orderlesson" id="doUnValidOrderLesson">
									<s:param name="id" value="id"></s:param>
								</s:url>
								<a title="不统计课时" type="button" class="btn confirm" href="${doUnValidOrderLesson}">
									<i class="icon-minus"></i>不统计课时
								</a>
							</s:if> <s:else>
								<s:url action="doValidOrderLesson" namespace="/orderlesson" id="doValidOrderLesson">
									<s:param name="id" value="id"></s:param>
								</s:url>
								<a title="计算课时" type="button" class="btn confirm" href="${doValidOrderLesson}">
									<i class="icon-plus"></i>统计课时
								</a>
							</s:else> <s:url action="doCancelOrderLesson" namespace="/orderlesson" id="doCancelOrderLesson">
								<s:param name="id" value="id"></s:param>
							</s:url> <a title="撤销该次订课" type="button" class="btn confirm" href="${doCancelOrderLesson}">撤销</a></td>
					</tr>
				</s:iterator>
			</tbody>
			<tfoot></tfoot>
		</table>
	</tiles:putAttribute>
</tiles:insertDefinition>